<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns="http://www.w3.org/1999/html">
<head>
    <meta charset="utf-8"/>
    <title>劲松商城后台</title>
    <div th:include="Admin/public/Common::head"></div>
    <script type="text/javascript">
        $(function (){
            $(".fahuo").click(function (){
                var id=$(this).attr("orderid");
                var pn=$(this).attr("pn");
                swal({
                    title: "确定发货?",
                    text: "发货之后不可撤回哟",
                    icon: "warning",
                    buttons: ["我再想想┭┮﹏┭┮", "确定发货！"],
                    dangerMode: true,
                    showCancelButton: true,
                })
                    .then((willDelete) => {
                        if (willDelete) {
                            $.ajax({
                                url:"http://localhost:8080/admin/fahuo",
                                type:"POST",
                                data: {orderid:id},
                                success:function (data){
                                    swal("此订单已经发货", {icon: "success",}).then(function (){
                                        location.href="http://localhost:8080/admin/order?pn="+pn;
                                    });
                                }
                            })
                        } else {
                            swal("想好了再点哟");
                        }
                    });
            })
            $(".jiakuai").click(function (){
                var id=$(this).attr("orderid");
                var pn=$(this).attr("pn");
                swal({
                    title: "确定加速?",
                    text: "速度非常快哟",
                    icon: "warning",
                    buttons: ["我再想想┭┮﹏┭┮", "确定加速！！！"],
                    dangerMode: true,
                    showCancelButton: true,
                })
                    .then((willDelete) => {
                        if (willDelete) {
                            $.ajax({
                                url:"http://localhost:8080/admin/fahuo",
                                type:"POST",
                                data: {orderid:id},
                                success:function (data){
                                    swal("物流小哥加快运输中", {icon: "success",}).then(function (){
                                        location.href="http://localhost:8080/admin/order?pn="+pn;
                                    });
                                }
                            })
                        } else {
                            swal("想好了再点哟");
                        }
                    });
            })
            $(".xiangqing").click(function (){
                var id=$(this).attr("orderid");
                location.href="http://localhost:8080/admin/orderdetail?OrderId="+id;
            })
        })
    </script>
</head>
<body>
<div class="main-wrap">
    <div th:include="Admin/public/Common::menu"></div>
    <div class="content-wrap">
        <div th:replace="Admin/public/Common::header"></div>
        <main class="main-cont content mCustomScrollbar">
            <div class="page-wrap">
                <!--开始::内容-->
                <section class="page-hd">
                    <header>
                        <h2 class="title"><i class="fa  fa-shopping-cart ">&nbsp;</i>订单管理</h2>
                    </header>
                    <hr>
                </section>
                <table class="table table-bordered table-striped table-hover">
                    <thead>
                    <tr>
                        <th>订单号</th>
                        <th>创建时间</th>
                        <th>订单总价</th>
                        <th>订单用户id</th>
                        <th>订单状态</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr class="cen" th:each="orders:${pages.list}">
                        <td th:text="${orders.orderId}"></td>
                        <td><a href="#" th:text="${orders.Timechange()}" style="color: #2E9EFE"></a></td>
                        <td th:text="'￥'+${orders.price}"></td>
                        <td th:text="${orders.userId}"></td>
                        <td  th:if="${orders.status!=2}" th:text="${orders.status}==1?'已发货':'未发货'"></td>
                        <td  th:if="${orders.status==2}" th:text="已收货" style="color: red"></td>
                        <td>
                            <button class="btn btn-info-outline radius size-l xiangqing" th:orderid="${orders.orderId}">查看订单</button>
                            <button th:if="${orders.status}==1" class="btn btn-info-outline radius size-l jiakuai" th:orderid="${orders.orderId}" th:pn="${pages.pageNum}">快马加鞭</button>
                            <button th:if="${orders.status}==0"class="btn btn-danger-outline radius size-xl fahuo" th:orderid="${orders.orderId}" th:pn="${pages.pageNum}">点击发货</button>
                        </td>
                    </tr>
                    </tbody>
                </table>
                <!--开始::结束-->
                <center>
                    <ul class="pagination justify-content-center">
                        <li class="page-item"><a href="#" th:href="@{/admin/order(pn=${pages.getPrePage()})}">上一页</a></li>
                        <li class="page-item" th:each="num:${pages.getNavigatepageNums()}">
                            <a th:if="${num==pages.getPageNum()}" href="#" th:text="${num}"
                               th:href="@{/admin/order(pn=${num})}" style="color: blue"></a>
                            <a th:if="${num!=pages.getPageNum()}" href="#" th:text="${num}"
                               th:href="@{/admin/order(pn=${num})}"></a>
                        </li>
                        <li class="page-item"><a href="#" th:href="@{/admin/order(pn=${pages.getNextPage()})}">下一页</a></li><br>
                    </ul>
                    <p th:text="当前+${pages.getPageNum()}+页+','+总共+${pages.getPages()}+页+','+总+${pages.getTotal()}+条记录"></p>
                </center>
            </div>
        </main>
        <div th:replace="Admin/public/Common::footer"></div>
    </div>
</div>
</body>
</html>
